#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>

int left, secs;

void handler(int sig){}

unsigned int snooze(unsigned int secs)
{
    left = sleep(secs);
    if (left >= 0)
        printf("Slept for %d of %d\n", secs-left, secs);
        
    return left;
}

int main(int argc, char *argv[])
{
    if (argc != 2)
    {
        printf("Usage: %s <secs>\n", argv[0]);
        exit(0);
    }

    if (signal(SIGINT, handler) == SIG_ERR)
    {
        printf("signal error!\n");
        exit(0);
    }

    secs = atoi(argv[1]);
    snooze(secs);

    return 0;
}
